<?php

require "../classes/FaresTo.class.php";
require "../classes/FaresDAO.class.php";
require "../classes/ConnectionFactory.class.php";
require "checksDate.action.php";

$date = new checksDate();
$fares = new FaresTo();
$cf = new ConnectionFactory();
$db = $cf->getConnection();
$dao = new FaresDAO($db);

$data = $date->dataAtualSimples();

$id = '';
$fares->setId($_POST['id']);
$fares->setFares($_POST['tarifa']);
$fares->setDescription($_POST['descricao']);
$fares->setDate($data);


$id = $fares->getId();


if (empty($id)) {
    $result = $dao->create($fares);
} else {
    $result = $dao->update($fares);
}
header("Location: ../index.php");

?>
